package com.atguigu.stgy.admin.controller;
import com.atguigu.stgy.admin.service.FeeKeyService;
import com.atguigu.stgy.model.entity.FeeKey;
import com.atguigu.stgy.model.result.R;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 杂项费用名称表(fee_key)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/admin/fee")
public class FeeKeyController {
/**
* 服务对象
*/
@Resource
private FeeKeyService feeKeyService ;


    //
    @Operation(summary = "查询杂费属性和值列表")
    @GetMapping("list")
    public R<List<FeeKeyVo>> list(){

        return R.ok(feeKeyService.listFeeKeyVos());
    }


  //  http://localhost:8080/admin/fee/key/saveOrUpdate
    @Operation(summary = "新增/更新 杂费信息属性")
    @PostMapping("key/saveOrUpdate")
    public  R saveOrUpdate(@RequestBody FeeKey feeKey){
        feeKeyService.saveOrUpdate(feeKey);
        return R.ok();
    }

  //  http://localhost:8080/admin/fee/key/deleteById?feeKeyId=7
    @DeleteMapping("key/deleteById")
    public R deleteById(@RequestParam("feeKeyId") Long id){
        return R.ok(feeKeyService.removeById(id));
    }
}
